<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>首页</title>
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="../../../css/mui.min.css" rel="stylesheet" />
    <link href="../css/common.css" rel="stylesheet" />
	<link rel="stylesheet" href="../../sitOperation/static/css/common.css" />	
	<link rel="stylesheet" href="../../sitOperation/static/css/terminalwork.css" />
    <style>
      /*九宫格样式*/
      *{ touch-action: pan-y; }
      .home_icon {
      	width: 100%;
      }
      
      .mui-content .mui-icon {
      	width: 100%;
      	padding: 0 26%;
      }
      
      .mui-grid-view.mui-grid-9 {
      	background: #fff;
      	padding: 10px 0;
      }
      
      .mui-grid-view.mui-grid-9 .mui-table-view-cell {
      	border: none;
      	padding: 5px 15px;
      }
      /*图标样式*/
      
      #lineChart {
      	width: 100%;
      	height: 340px;
      	background: #fff;
      	padding: 16px 15px;
      	margin-top: 10px;
      }
      /*弹出框*/
      
      .mui-popover-add {
      	top: 180px!important;
      	width: 80%;
      	margin-left: 10%;
      	background: #ffffff;
      	padding-top: 10px;
        /* z-index: 9999; */
      }
      
      .sp-title {
      	color: #333;
      	width: 100%;
      	text-align: center;
      	padding: 10px 0px;
      	border-bottom: 1px solid #ededed;
      }
      
      .sp-group {
      	width: 92%;
      	margin-left: 4%;
      	display: flex;
      	/*border: 1px solid #0077dc;*/
      	height: 43px;
      	border-radius: 5px;
      	align-items: center;
      	margin-top: 25px;
      }
      .sp-group label{
      	font-size: 0.83rem;
      }
      
      .sp-group input {
      	background: #f3f3f3;
      	border: 1px solid #ededed;
      }
      
      .sp-submit {
      	margin-top: 20px;
      	height: 46px;
      	width: 100%;
      	border-top: 1px solid #C1C1C1;
      	display: flex;
      }
      
      .sp-submit div:first-child {
      	border-right: 1px solid #CCCCCC;
      }
      
      .sp-submit div {
      	width: 50%;
      	text-align: center;
      	line-height: 46px;
      	font-size: 15px;
      }
      
      .sp-submit div:nth-child(2) {
      	color: #0077dc;
      }
      .popCotent{
        padding: 15px;
      }
      .popCotent p{
        text-align: center;
        color: #FF0000;
      }
      .mui-input-row{
        border:1px solid #efefef;
        border-radius: 6px;
      }
      .mui-input-group:before,.mui-input-group:after{
        height: 0;
      }
      .mui-input-group .mui-input-row:after{
        height: 0;
      }
	  .explain-dialog .home_icon {
			width: 50%;
			border-radius: 5px; 
		}
    </style>
  </head>
  <body>
	  <div id="page">
    <div id="container">
      <header class="mui-bar mui-bar-nav">
        <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
        <h1 class="mui-title">移动两票</h1>
      </header>
      <div class="mui-content" style="margin-top: 0px;">
        <ul class="mui-table-view mui-grid-view mui-grid-9" style="margin-top: 0px;">
          <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-4" @click.stop="page1('zwbh')">
            <a href="javascript:;">
              <span class="mui-icon ">
                <img src="../img/record.png" class="home_icon" />
              </span>
              <div class="mui-media-body">早晚班会</div>
            </a>
          </li>
		  <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-4" @click.stop="page1('yxrz')">
		    <a href="javascript:;">
		      <span class="mui-icon ">
		        <img src="../img/safe.png" class="home_icon" />
		      </span>
		      <div class="mui-media-body">运行日志</div>
		    </a>
		  </li>
		  <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-4" @click.stop="page1('lp')">
		    <a href="javascript:;">
		      <span class="mui-icon ">
		        <img src="../img/group_home_1.png" class="home_icon" />
		      </span>
		      <div class="mui-media-body">两票</div>
              <!-- <div class="mui-media-body">深化应用</div> -->
            </a>
          </li>
		  <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-4" @click.stop="page2()">
		    <a href="javascript:;">
		      <span class="mui-icon ">
		        <img src="../img/n2.png" class="home_icon" />
		      </span>
		      <div class="mui-media-body">班会签到</div>
		    </a>
		  </li>
        </ul>
      </div>
	  </div>
	  </div>
	  
	  
  </body>

  <script src="../../../js/mui.min.js"></script>
  <script src="../../../js/jquery-1.7.2.min.js"></script>
  <script src="../../../js/vue.js"></script>
  <script src="../js/mkeyplus.base.js"></script>
  <script src="../formal/js/api.js"></script>
  <script src="./js/base64.js"></script>
  <script src="./js/xxtea.js"></script>
  <script src="./js/shoyu-xxtea.js"></script>
  <!-- 其他项目4A登录 -->
  <script src="./js/internalApp4Alogin.js"></script>
  
  <script type="text/javascript" charset="utf-8">
    var htapi = new HTGlobal();
    var floatw = null;
    mui.init({
      swipeBack: true //启用右滑关闭功能
    });
	var page = new Vue({
      el: '#page',
      data: {
		isShowMenuChoose:false,
		flag:true,
		username:'',
        password: '',
		loginType:2,//测试2,正式1
		loginCount:0,
		isShowSitIn:false,
		isShowSit:false,
		isShowControl:false, 
		userInfo:'',
		curtype:3,
		
		menuInfo:{
			userSelectMenu:''
		}, // 已保存的菜单 
		chooseMenuList:'', // 修改的菜单
      },
      methods:{
		  page1(type){
			  // mui.toast('待4A上线开放！');return;
			  console.log('curtype=='+this.curtype);
			  if(this.curtype == 1){
				  mui.toast('当前无网络！');return;
			  }
			  var C = G_Config();
			  urlz = C.protocol+C.host+C.LP_path
			  child4Alogin.tourbillon(urlz,type)
			 
		  },
		  page2(){
			  if(this.curtype == 1){
			  	mui.toast('当前无网络！');return;
			  }
			  var C = G_Config();
			  urlz = C.protocol+C.host+C.LP_path
			  child4Alogin.signIn(urlz)
		  },
		  page3(){
			  /** 一机一档页面
			   * @method page3
			   * @param {空}
			   * @return {空}
			  */
			 //mui.toast('功能正在完善中，敬请期待！');return;
			 if(this.curtype == 1){
			 	 mui.toast('当前无网络！');return;
			 }
			 var C = G_Config();
			 child4Alogin.ddms(C.protocol+C.host+C.YJYD_path);
			 return;
		  },
		  page5(){
			  /** 巡回检查
			   * @method page5
			   * @param {空}
			   * @return {空}
			  */
			 if(this.curtype == 1){
				 var btnArray = ['取消', '确定'];
				 mui.confirm('当前无网络，是否离线登录？', '提示', btnArray, function(e) {
				   if (e.index == 1) { 
				    console.log('离线登录');
					 mui.openWindow({
						  url: '../../jiankong/jiankong.html',
						  id: '../jiankong/jiankong.html',
						  extras: {}
					 });
				   }
				 })
			 }else{
				var C = G_Config();
				child4Alogin.jiankong(C.protocol+C.host+C.XJ_path); 
			 }
		  },
		  submit(){
			  //登录
		  },
		  tblLogin(params){
			/** 提交登录
			 * @method tblLogin
			 * @param {params} 登录完成后的参数
			 * @return {空}
			*/  
		   if(this.password==''){
		     mui.toast('请输入密码');
		   		return;
		   }
		   
		   var userName = this.username;
		   
		   var password = this.password;
		   //保存用户信息
		   var cvs = {
		         url: params.url,
		         id: params.id,
		         extras: {
		           username:userName,
		           password:password,
				   topage:params.topage||'',
				   loginType:page.loginType
		         }
		   }
		   
		   if(this.loginCount==0){
			   //第一次登录
			   this.testLogin(()=>{
				   page.loginCount++
				   page.toPage(cvs)
			   })
			   return;
		   }
		  
				page.hideTblLogin()
		        return page.toPage(cvs)
		  
		   /* end tblLogin */
		  },
		  toPage(params){
			/** 跳转到对应页面
			 * @method toPage
			 * @param{params}页面对象参数
			 * @return {空}
			*/
		   params.waiting={
           	autoShow:false
           }
		   mui.openWindow(params);
		  },
		  hideTblLogin(){
			  /** 隐藏深化应用登录
			   * @method hideTblLogin
			   * @param{空}
			   * @return {空}
			  */
			 mui('#topPopover1').popover('hide');
		  },
		  showTblLogin(){
			  /** 显示深化应用登录
			   * @method showTblLogin
			   * @param{空}
			   * @return {空}
			  */
			  var main = plus.webview.currentWebview().opener();
			  mui.fire(main,'popUp');
			  mui('#topPopover1').popover('show');
		  },
		  checkTblLogin(){
			  /** 检测是否登录深化应用
			   * @method checkTblLogin
			   * @param{空}
			   * @return {空}
			  */
			 var T = this
			 if(T.username && T.password){
				 //已存在用户名密码
				 return true
			 }else{
				 //未有用户名密码-弹出登录框
				 var _user = localStorage.getItem('groupUser');
				 //console.log(plus.webview.currentWebview().id)
				 page.showTblLogin()
				 //mui.trigger(document.querySelector('.sp-submit-sure1'),'tap');
				 console.log(_user)
				 _user=JSON.parse(_user)
				 page.username =_user.userName
				 
				 return false
			 }
		  },
		  testLogin(callback){
			 /** 初测试登录
			  * @method testLogin
			  * @param{空}
			  * @return {空}
			 */ 
         plus.nativeUI.showWaiting('登录中...');
          var userName = page.username;
          var password = page.password;
          var SHYY_url = mui.baseWApp.serverUrl+'/../smartreport-api/sso/login?platform=A&loginType='+page.loginType;
       
           mui.ajax({
             url: SHYY_url,
             headers: {
                 'Authorization': 'Basic '+ Base64.encode(userName + ':'+ password) //自定义请求头信息
             },
             timeout: 3000,
             dataType: 'json',
             type: 'post',
             success: function(res) {
               if(res.success){
				   callback()
               }else{
				   page.username = ''
                  mui.toast('登录错误！请核对账户名及密码！');
               }
				page.hideTblLogin()
                plus.nativeUI.closeWaiting()
             }})

		  }
      },
    })
    mui.plusReady(function() {
		page.curtype = plus.networkinfo.getCurrentType();
	})
    $('#record').on('tap', function() {
	  console.log('curtype='+page.curtype);
	  if(page.curtype == 1){
	  	 mui.toast('当前无网络！');return;
	  }
      mui.openWindow({
        url: './personnel_management.html',
        id: './personnel_management.html',
        extras: {},
        waiting: {
          autoShow: false
        }
      })
    });

    $('#notice').on('tap', function() {
      mui.toast('功能正在完善中，敬请期待！');return;
      var user = localStorage.getItem('outUser'),
        openPath = '../formal/registration_on.html';
      //console.log(user);return;
      if (user) {
        user = JSON.parse(user);
        if (user.notice && user.notice != 0) {
          openPath = './admission.html';
        }
      }
      //console.log(openPath);return;	
      mui.openWindow({
        url: openPath,
        id: openPath,
        extras: {},
        waiting: {
          autoShow: false
        }
      })
    });
    $('#safe').on('tap', function() {
      mui.toast('功能正在完善中，敬请期待！');return;
      mui.openWindow({
        url: './safe.html',
        id: './safe.html',
        extras: {},
        waiting: {
          autoShow: false
        }
      })
    });
    $('#edu').on('tap', function() {
      mui.toast('功能正在完善中，敬请期待！');return;
      mui.openWindow({
        url: '../edu/index.html',
        id: '../edu/index.html',
        extras: {},
        waiting: {
          autoShow: false
        }
      })
    });
    $('#exam').on('tap', function() {
      mui.toast('功能正在完善中，敬请期待！');return;
      mui.openWindow({
        url: '../examScore/index.html',
        id: '../examScore/index.html',
        extras: {},
        waiting: {
          autoShow: false
        }
      })
    });
    mui.plusReady(function() {
      var new_back = mui.back;
      mui.back = function() {
		  let page = plus.webview.currentWebview();
		  if(page.children().length == 0){
			  page.close();
		  }
	  }
    })
	
  </script>
</html>
